package WaiBao;

import java.util.Arrays;

public class ZhaoZhongZe {
    public static void main(String[] args) {
        String[] name = {"李碧婷(班长)", "李海(副班长)", "小李(学习委员)", "王多多(体育委员)", "李子豪", "争上游", "张思文", "张倩倩", "翟依", "程正旺", "陈显超", "王甜甜",
                "宋洁伦", "张宇星", "王鸿烈", "张哥哥", "司子玉", "凌耀东", "张晓华", "林中会", "杨过", "白水", "李训", "马云", "李海", "王子腾", "雷军", "李俊哲",
                "张丽滋", "赵忠泽(学生)"};//考生本人:赵忠泽(学生))
        int[] age = {19, 20, 19, 18, 19, 21, 20, 21, 20, 20, 18, 19, 20, 20, 20, 19, 18, 21, 18, 18, 20, 19, 20, 20, 20, 18, 20, 21, 19, 20};//考生年龄：20

        double[] haoyu1 ={88, 92, 84, 90, 79, 69, 78, 89, 80, 80, 71, 87, 85, 89, 64, 68, 95, 69, 96, 88, 92, 91, 95, 65, 79, 74, 94, 74, 88, 95};
        double[] haoyu2 = {77, 85, 69, 76, 74, 77, 78, 64, 90, 70, 90, 77, 86, 95, 64, 65, 76, 99, 65, 98, 72, 71, 95, 86, 75, 85, 85, 65, 82, 95};
        double[] haoyu3 = {84, 74, 84, 85, 77, 66, 78, 68, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 77, 72, 89, 96};


        double juanjuan1;//代表每个学生的总分
        double juanjuan2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            juanjuan1 = haoyu1[i] + haoyu2[i] + haoyu3[i];
//            juanjuan2 = (juanjuan1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + juanjuan1);
//            System.out.println(name[i] + "的平均分为:" + juanjuan2);
//        }


        double jitui1 = 0, jitui2 = 0;
//        double[] hefei = new double[30];
//        for (int i = 0; i < 30; i++) {
//            jitui1 = haoyu1[i] + haoyu2[i] + haoyu3[i];
//            jitui2 = (jitui1* 1.0) / 3;
//            hefei[i] = jitui2;
//        }
//
//        for (int i = 0; i <hefei.length - 1; i++) {
//            for (int j = 0; j <hefei.length - i - 1; j++) {
//                if (hefei[j] < hefei[j + 1]) {
//                    double tep = hefei[j];
//                    hefei[j] = hefei[j + 1];
//                    hefei[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(hefei[i]);
//        }

        double dami1 = 0,dami2 = 0, dami3 = 0;//计算每门课的平均分
        double jinxin1 = 0,jinxin2 = 0,jinxin3 = 0;//计算每门课标准差
        double weilian1 = 0,weilian2 = 0,weilian3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <haoyu1.length; i++) {
            he += haoyu1[i];
        }
        dami1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + dami1);
        double Sum = 0;
        for (int i = 0; i < haoyu2.length; i++) {
            Sum += haoyu2[i];
        }
        dami2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + dami2);
        double sum = 0;
        for (int i = 0; i < haoyu3.length; i++) {
            sum += haoyu3[i];
        }
        dami3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + dami3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < haoyu1.length; i++) {
            c1 += (haoyu1[i] - dami1) * (haoyu1[i] - dami1);
        }
        jinxin1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + jinxin1);
        for (int i = 0; i < haoyu2.length; i++) {
            c2 += (haoyu2[i] - dami2) * (haoyu2[i] - dami2);
        }
        jinxin2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + jinxin2);

        for (int i = 0; i < haoyu3.length; i++) {
            c3 += (haoyu3[i] - dami3) * (haoyu3[i] - dami3);
        }
        jinxin3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + jinxin3);
////
//
//
        Arrays.sort(haoyu1);
        Arrays.sort(haoyu2);
        Arrays.sort(haoyu3);
        weilian1 = (haoyu1[14] + haoyu2[15]) * 1.0 / 2;
        weilian2 = (haoyu2[14] + haoyu2[15]) * 1.0 / 2;
        weilian3 = (haoyu3[14] + haoyu3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + weilian1);
        System.out.println("物理化学的中位数为:" + weilian2);
        System.out.println("电子与电工技术的中位数为:" + weilian3);



    }
}
